# Load Necessary Packages
library(foreign)
library(stargazer)
library(lavaan)
library(plotrix)
library(ggplot2)
library(grid)
library(gridExtra)
library(ggpubr)
library(margins)
library(dplyr)
library(semTools)
library(car)

# Load Dataset
setwd("/users/josephphillips/Dropbox/Projects/Regional Resentment")
data <- read.csv("England Resentment Dataverse.csv",header=T,sep=",")

# Clean Dataset
data$immigration7 <- as.numeric(data$immigration7)
data$british_born <- as.numeric(data$british_born)
data$white <- as.numeric(data$white)
data$income_000 <- ifelse(as.numeric(as.factor(data$income))==1,15.6,ifelse(as.numeric(as.factor(data$income))==2,150,ifelse(as.numeric(as.factor(data$income))==3,26,ifelse(as.numeric(as.factor(data$income))==4,36.4,ifelse(as.numeric(as.factor(data$income))==5,46.8,ifelse(as.numeric(as.factor(data$income))==6,5,ifelse(as.numeric(as.factor(data$income))==7,75,ifelse(as.numeric(as.factor(data$income))==8,0,NA))))))))
data$torylikely <- as.numeric(data$torylikely)
data$labourlikely <- as.numeric(data$labourlikely)
data$costofliving <- as.numeric(data$costofliving)
data$northern_resentment1a <- as.numeric(data$northern_resentment1a)
data$northern_resentment2a <- as.numeric(data$northern_resentment2a)
data$northern_resentment3a <- as.numeric(data$northern_resentment3a)
data$northern_resentment4a <- as.numeric(data$northern_resentment4a)
data$northern_resentment5a <- as.numeric(data$northern_resentment5a)
data$northern_resentment6a <- as.numeric(data$northern_resentment6a)
data$northern_resentment7a <- as.numeric(data$northern_resentment7a)
data$northern_resentment8a <- as.numeric(data$northern_resentment8a)
data$northern_resentment9a <- as.numeric(data$northern_resentment9a)
data$southern_resentment1a <- as.numeric(data$southern_resentment1a)
data$southern_resentment2a <- as.numeric(data$southern_resentment2a)
data$southern_resentment3a <- as.numeric(data$southern_resentment3a)
data$southern_resentment4a <- as.numeric(data$southern_resentment4a)
data$southern_resentment5a <- as.numeric(data$southern_resentment5a)
data$southern_resentment6a <- as.numeric(data$southern_resentment6a)
data$southern_resentment7a <- as.numeric(data$southern_resentment7a)
data$southern_resentment8a <- as.numeric(data$southern_resentment8a)
data$southern_resentment9a <- as.numeric(data$southern_resentment9a)
data$london_resent1a <- as.numeric(data$london_resent1a)
data$london_resent2a <- as.numeric(data$london_resent2a)
data$london_resent3a <- as.numeric(data$london_resent3a)
data$london_resent4a <- as.numeric(data$london_resent4a)
data$london_resent5a <- as.numeric(data$london_resent5a)
data$london_resent6a <- as.numeric(data$london_resent6a)
data$london_resent7a <- as.numeric(data$london_resent7a)
data$london_resent8a <- as.numeric(data$london_resent8a)
data$london_resent9a <- as.numeric(data$london_resent9a)
data$elsewhere_resent1a <- as.numeric(data$elsewhere_resent1a)
data$elsewhere_resent2a <- as.numeric(data$elsewhere_resent2a)
data$elsewhere_resent3a <- as.numeric(data$elsewhere_resent3a)
data$elsewhere_resent4a <- as.numeric(data$elsewhere_resent4a)
data$elsewhere_resent5a <- as.numeric(data$elsewhere_resent5a)
data$elsewhere_resent6a <- as.numeric(data$elsewhere_resent6a)
data$elsewhere_resent7a <- as.numeric(data$elsewhere_resent7a)
data$elsewhere_resent8a <- as.numeric(data$elsewhere_resent8a)
data$elsewhere_resent9a <- as.numeric(data$elsewhere_resent9a)
data$privateeducation <- ifelse(data$privateeducation=="Yes",1,0)
data$ft_tory <- data$ft_tory/100
data$ft_labour <- data$ft_labour/100
data$torylikely <- (data$torylikely-1)/4
data$labourlikely <- (data$labourlikely-1)/4

# Table 1 (Note: Higher Values = Agreement)
data %>% count(northern_resentment1a) %>% filter(!is.na(northern_resentment1a)) %>% mutate(freq=n*100/sum(n))
data %>% count(southern_resentment1a) %>% filter(!is.na(southern_resentment1a)) %>% mutate(freq=n*100/sum(n))
data %>% count(northern_resentment2a) %>% filter(!is.na(northern_resentment2a)) %>% mutate(freq=n*100/sum(n))
data %>% count(southern_resentment2a) %>% filter(!is.na(southern_resentment2a)) %>% mutate(freq=n*100/sum(n))
data %>% count(northern_resentment3a) %>% filter(!is.na(northern_resentment3a)) %>% mutate(freq=n*100/sum(n))
data %>% count(southern_resentment3a) %>% filter(!is.na(southern_resentment3a)) %>% mutate(freq=n*100/sum(n))
data %>% count(northern_resentment4a) %>% filter(!is.na(northern_resentment4a)) %>% mutate(freq=n*100/sum(n))
data %>% count(southern_resentment4a) %>% filter(!is.na(southern_resentment4a)) %>% mutate(freq=n*100/sum(n))
data %>% count(northern_resentment5a) %>% filter(!is.na(northern_resentment5a)) %>% mutate(freq=n*100/sum(n))
data %>% count(southern_resentment5a) %>% filter(!is.na(southern_resentment5a)) %>% mutate(freq=n*100/sum(n))
data %>% count(northern_resentment6a) %>% filter(!is.na(northern_resentment6a)) %>% mutate(freq=n*100/sum(n))
data %>% count(southern_resentment6a) %>% filter(!is.na(southern_resentment6a)) %>% mutate(freq=n*100/sum(n))
data %>% count(northern_resentment7a) %>% filter(!is.na(northern_resentment7a)) %>% mutate(freq=n*100/sum(n))
data %>% count(southern_resentment7a) %>% filter(!is.na(southern_resentment7a)) %>% mutate(freq=n*100/sum(n))
data %>% count(northern_resentment8a) %>% filter(!is.na(northern_resentment8a)) %>% mutate(freq=n*100/sum(n))
data %>% count(southern_resentment8a) %>% filter(!is.na(southern_resentment8a)) %>% mutate(freq=n*100/sum(n))

# Table 2 (Note: Higher values = Agreement)
data %>% count(elsewhere_resent1a) %>% filter(!is.na(elsewhere_resent1a)) %>% mutate(freq=n/sum(n))
data %>% count(london_resent1a) %>% filter(!is.na(london_resent1a)) %>% mutate(freq=n/sum(n))
data %>% count(elsewhere_resent2a) %>% filter(!is.na(elsewhere_resent2a)) %>% mutate(freq=n/sum(n))
data %>% count(london_resent2a) %>% filter(!is.na(london_resent2a)) %>% mutate(freq=n/sum(n))
data %>% count(elsewhere_resent3a) %>% filter(!is.na(elsewhere_resent3a)) %>% mutate(freq=n/sum(n))
data %>% count(london_resent3a) %>% filter(!is.na(london_resent3a)) %>% mutate(freq=n/sum(n))
data %>% count(elsewhere_resent4a) %>% filter(!is.na(elsewhere_resent4a)) %>% mutate(freq=n/sum(n))
data %>% count(london_resent4a) %>% filter(!is.na(london_resent4a)) %>% mutate(freq=n/sum(n))
data %>% count(elsewhere_resent5a) %>% filter(!is.na(elsewhere_resent5a)) %>% mutate(freq=n/sum(n))
data %>% count(london_resent5a) %>% filter(!is.na(london_resent5a)) %>% mutate(freq=n/sum(n))
data %>% count(elsewhere_resent6a) %>% filter(!is.na(elsewhere_resent6a)) %>% mutate(freq=n/sum(n))
data %>% count(london_resent6a) %>% filter(!is.na(london_resent6a)) %>% mutate(freq=n/sum(n))
data %>% count(elsewhere_resent7a) %>% filter(!is.na(elsewhere_resent7a)) %>% mutate(freq=n/sum(n))
data %>% count(london_resent7a) %>% filter(!is.na(london_resent7a)) %>% mutate(freq=n/sum(n))
data %>% count(elsewhere_resent8a) %>% filter(!is.na(elsewhere_resent8a)) %>% mutate(freq=n/sum(n))
data %>% count(london_resent8a) %>% filter(!is.na(london_resent8a)) %>% mutate(freq=n/sum(n))

# Table 3
northern <- 'ns =~ northern_resentment1a+northern_resentment2a+northern_resentment3a+northern_resentment4a+northern_resentment5a+northern_resentment6a+northern_resentment7a+northern_resentment8a'
southern <- 'ns =~ southern_resentment1a+southern_resentment2a+southern_resentment3a+southern_resentment4a+southern_resentment5a+southern_resentment6a+southern_resentment7a+southern_resentment8a'
london <- 'ns =~ london_resent1a+london_resent2a+london_resent3a+london_resent4a+london_resent5a+london_resent6a+london_resent7a+london_resent8a'
elsewhere <-'ns =~ elsewhere_resent1a+elsewhere_resent2a+elsewhere_resent3a+elsewhere_resent4a+elsewhere_resent5a+elsewhere_resent6a+elsewhere_resent7a+elsewhere_resent8a'

psych::alpha(cbind.data.frame(data$northern_resentment1a,data$northern_resentment2a,data$northern_resentment3a,data$northern_resentment4a,data$northern_resentment5a,data$northern_resentment6a,data$northern_resentment7a,data$northern_resentment8a))
psych::alpha(cbind.data.frame(data$southern_resentment1a,data$southern_resentment2a,data$southern_resentment3a,data$southern_resentment4a,data$southern_resentment5a,data$southern_resentment6a,data$southern_resentment7a,data$southern_resentment8a))
psych::alpha(cbind.data.frame(data$elsewhere_resent1a,data$elsewhere_resent2a,data$elsewhere_resent3a,data$elsewhere_resent4a,data$elsewhere_resent5a,data$elsewhere_resent6a,data$elsewhere_resent7a,data$elsewhere_resent8a))
psych::alpha(cbind.data.frame(data$london_resent1a,data$london_resent2a,data$london_resent3a,data$london_resent4a,data$london_resent5a,data$london_resent6a,data$london_resent7a,data$london_resent8a))


northern.cfa <- cfa(northern,data=data) # RMSEA=.052 [90% CI: .030, .073], SRMR=.034, CFI=.960, TLI=.971
southern.cfa <- cfa(southern,data=data) # RMSEA=.060 [90% CI: .041, .081], SRMR=.038, CFI=.967, TLI=.953
london.cfa <- cfa(london,data=data) # RMSEA=.100 [90% CI: .058, .141], SRMR=.073, CFI=.884, TLI=.838
elsewhere.cfa <- cfa(elsewhere,data=data) # RMSEA=.063 [90% CI: .049, .078], SRMR=.033, CFI=.964, TLI=.949

# Figure 1
## Create Figure Data
resentment.byregion <- data %>% group_by(region) %>% summarise(nresentment=mean(northernresentment,na.rm=T),nresentment_se=std.error(northernresentment,na.rm=T),
                                                               sresentment=mean(southernresentment,na.rm=T),sresentment_se=std.error(southernresentment,na.rm=T),
                                                               lresentment=mean(elsewhereresentment,na.rm=T),lresentment_se=std.error(elsewhereresentment,na.rm=T))

resentment.byregion$nresentment_lci <- resentment.byregion$nresentment-(1.96*resentment.byregion$nresentment_se)
resentment.byregion$nresentment_uci <- resentment.byregion$nresentment+(1.96*resentment.byregion$nresentment_se)
resentment.byregion$sresentment_lci <- resentment.byregion$sresentment-(1.96*resentment.byregion$sresentment_se)
resentment.byregion$sresentment_uci <- resentment.byregion$sresentment+(1.96*resentment.byregion$sresentment_se)
resentment.byregion$lresentment_lci <- resentment.byregion$lresentment-(1.96*resentment.byregion$lresentment_se)
resentment.byregion$lresentment_uci <- resentment.byregion$lresentment+(1.96*resentment.byregion$lresentment_se)

plotdata.resentmentbyregion <- data.frame(Region=factor(c("London","S East","S West","E Eng","W Mid","E Mid","Y and H","N West","N East","London","S East","S West","E Eng","W Mid","E Mid","Y and H","N West","N East"),levels=c("London","S East","S West","E Eng","W Mid","E Mid","Y and H","N West","N East")),
                                          Type=factor(c(rep("Southern",4),rep("Northern",5),"Central",rep("Peripheral",8)),levels=c("Southern","Northern","Central","Peripheral")),
                                          resentment=c(resentment.byregion$sresentment[c(3,6,7,2)],resentment.byregion$nresentment[c(8,1,9,5,4)],mean(data$londonresentment,na.rm=T),resentment.byregion$lresentment[c(6,7,2,8,1,9,5,4)]),
                                          resentment_lci=c(c(resentment.byregion$sresentment_lci[c(3,6,7,2)],resentment.byregion$nresentment_lci[c(8,1,9,5,4)],mean(data$londonresentment,na.rm=T)-(1.96*std.error(data$londonresentment,na.rm=T)),resentment.byregion$lresentment_lci[c(6,7,2,8,1,9,5,4)])),
                                          resentment_uci=c(c(resentment.byregion$sresentment_uci[c(3,6,7,2)],resentment.byregion$nresentment_uci[c(8,1,9,5,4)],mean(data$londonresentment,na.rm=T)+(1.96*std.error(data$londonresentment,na.rm=T)),resentment.byregion$lresentment_uci[c(6,7,2,8,1,9,5,4)])))
## Create Figure
p.resentmentbyregion <- ggplot(plotdata.resentmentbyregion,aes(x=Region,y=(resentment*4)+1,group=Type,color=Type)) + geom_point(position=position_dodge(0.6)) + geom_errorbar(aes(ymin=(resentment_lci*4)+1,ymax=(resentment_uci*4)+1),lwd=0.5,width=0.1,position=position_dodge(0.6)) + theme_bw() + scale_color_manual(name="Resentment Type",values=c("#000000", "#E69F00", "#56B4E9","#009E73")) + scale_y_continuous(name="Resentment",limits=c(1,5)) + theme(legend.position="bottom")

## Differences in Resentment Type by Region
t.test(subset(data,region=="London")$londonresentment,subset(data,region=="London")$southernresentment)
t.test(subset(data,region=="South East")$elsewhereresentment,subset(data,region=="South East")$southernresentment)
t.test(subset(data,region=="South West")$elsewhereresentment,subset(data,region=="South West")$southernresentment)
t.test(subset(data,region=="East of England")$elsewhereresentment,subset(data,region=="East of England")$southernresentment)
t.test(subset(data,region=="West Midlands")$elsewhereresentment,subset(data,region=="West Midlands")$northernresentment)
t.test(subset(data,region=="East Midlands")$elsewhereresentment,subset(data,region=="East Midlands")$northernresentment)
t.test(subset(data,region=="Yorkshire and the Humber")$elsewhereresentment,subset(data,region=="Yorkshire and the Humber")$northernresentment)
t.test(subset(data,region=="North West")$elsewhereresentment,subset(data,region=="North West")$northernresentment)
t.test(subset(data,region=="North East")$elsewhereresentment,subset(data,region=="North East")$northernresentment)
t.test((subset(data,region=="West Midlands" | region=="East Midlands" | region=="Yorkshire nad the Humber" | region=="North West" | region=="North East")$elsewhereresentment*4)+1,(subset(data,region=="South East" | region=="South West" | region=="East of England")$elsewhereresentment*4)+1)

# Figure 2
## Northern Resentment and Con Warmth (Table SI11)
si11.bare <- lm(ft_tory~northernresentment,data=data)
si11.demogs <- lm(ft_tory~northernresentment+longlive+age+male+white+income_000,data=data)
si11.attitudes <- lm(ft_tory~northernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si11.full <- lm(ft_tory~northernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Northern Resentment and Con Voting (Table SI12)
si12.bare <- lm(torylikely~northernresentment,data=data)
si12.demogs <- lm(torylikely~northernresentment+longlive+age+male+white+income_000,data=data)
si12.attitudes <- lm(torylikely~northernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si12.full <- lm(torylikely~northernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Northern Resentment and Lab Warmth (Table SI13)
si13.bare <- lm(ft_labour~northernresentment,data=data)
si13.demogs <- lm(ft_labour~northernresentment+longlive+age+male+white+income_000,data=data)
si13.attitudes <- lm(ft_labour~northernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si13.full <- lm(ft_labour~northernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Northern Resentment and Lab Voting (Table SI14)
si14.bare <- lm(labourlikely~northernresentment,data=data)
si14.demogs <- lm(labourlikely~northernresentment+longlive+age+male+white+income_000,data=data)
si14.attitudes <- lm(labourlikely~northernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si14.full <- lm(labourlikely~northernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Southern Resentment and Con Warmth (Table SI15)
si15.bare <- lm(ft_tory~southernresentment,data=data)
si15.demogs <- lm(ft_tory~southernresentment+longlive+age+male+white+income_000,data=data)
si15.attitudes <- lm(ft_tory~southernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si15.full <- lm(ft_tory~southernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Southern Resentment and Con Voting (Table SI16)
si16.bare <- lm(torylikely~southernresentment,data=data)
si16.demogs <- lm(torylikely~southernresentment+longlive+age+male+white+income_000,data=data)
si16.attitudes <- lm(torylikely~southernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si16.full <- lm(torylikely~southernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Southern Resentment and Lab Warmth (Table SI17)
si17.bare <- lm(ft_labour~southernresentment,data=data)
si17.demogs <- lm(ft_labour~southernresentment+longlive+age+male+white+income_000,data=data)
si17.attitudes <- lm(ft_labour~southernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si17.full <- lm(ft_labour~southernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Southern Resentment and Lab Voting (Table SI18)
si18.bare <- lm(labourlikely~southernresentment,data=data)
si18.demogs <- lm(labourlikely~southernresentment+longlive+age+male+white+income_000,data=data)
si18.attitudes <- lm(labourlikely~southernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si18.full <- lm(labourlikely~southernresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Peripheral Resentment and Con Warmth (Table SI19)
si19.bare <- lm(ft_tory~elsewhereresentment,data=data)
si19.demogs <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000,data=data)
si19.attitudes <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si19.full <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Peripheral Resentment and Con Voting (Table SI20)
si20.bare <- lm(torylikely~elsewhereresentment,data=data)
si20.demogs <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000,data=data)
si20.attitudes <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si20.full <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Peripheral Resentment and Lab Warmth (Table SI21)
si21.bare <- lm(ft_labour~elsewhereresentment,data=data)
si21.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data)
si21.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si21.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Peripheral Resentment and Lab Voting (Table SI22)
si22.bare <- lm(labourlikely~elsewhereresentment,data=data)
si22.demogs <- lm(labourlikely~elsewhereresentment+longlive+age+male+white+income_000,data=data)
si22.attitudes <- lm(labourlikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si22.full <- lm(labourlikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)
## Create Figure Data
f2data <- data.frame(predictor=factor(c(rep("Northern",16),rep("Southern",16),rep("Peripheral",16)),levels=c("Northern","Southern","Peripheral")),
                     Outcome=factor(c(rep("Con FT",4),rep("Con Vote",4),rep("Lab FT",4),rep("Lab Vote",4),rep("Con FT",4),rep("Con Vote",4),rep("Lab FT",4),rep("Lab Vote",4),rep("Con FT",4),rep("Con Vote",4),rep("Lab FT",4),rep("Lab Vote",4)),levels=c("Con FT","Con Vote","Lab FT","Lab Vote")),
                     Model=factor(c(rep(c("Bare","Demogs","Attitudes","Full"),12)),levels=c("Bare","Demogs","Attitudes","Full")),
                     Effect=c(summary(si11.bare)$coefficients[2,1], summary(si11.demogs)$coefficients[2,1], summary(si11.attitudes)$coefficients[2,1], summary(si11.full)$coefficients[2,1], summary(si12.bare)$coefficients[2,1], summary(si12.demogs)$coefficients[2,1], summary(si12.attitudes)$coefficients[2,1], summary(si12.full)$coefficients[2,1], summary(si13.bare)$coefficients[2,1], summary(si13.demogs)$coefficients[2,1], summary(si13.attitudes)$coefficients[2,1], summary(si13.full)$coefficients[2,1], summary(si14.bare)$coefficients[2,1], summary(si14.demogs)$coefficients[2,1], summary(si14.attitudes)$coefficients[2,1], summary(si14.full)$coefficients[2,1], summary(si15.bare)$coefficients[2,1], summary(si15.demogs)$coefficients[2,1], summary(si15.attitudes)$coefficients[2,1], summary(si15.full)$coefficients[2,1], summary(si16.bare)$coefficients[2,1], summary(si16.demogs)$coefficients[2,1], summary(si16.attitudes)$coefficients[2,1], summary(si16.full)$coefficients[2,1], summary(si17.bare)$coefficients[2,1], summary(si17.demogs)$coefficients[2,1], summary(si17.attitudes)$coefficients[2,1], summary(si17.full)$coefficients[2,1], summary(si18.bare)$coefficients[2,1], summary(si18.demogs)$coefficients[2,1], summary(si18.attitudes)$coefficients[2,1], summary(si18.full)$coefficients[2,1], summary(si19.bare)$coefficients[2,1], summary(si19.demogs)$coefficients[2,1], summary(si19.attitudes)$coefficients[2,1], summary(si19.full)$coefficients[2,1], summary(si20.bare)$coefficients[2,1], summary(si20.demogs)$coefficients[2,1], summary(si20.attitudes)$coefficients[2,1], summary(si20.full)$coefficients[2,1], summary(si21.bare)$coefficients[2,1], summary(si21.demogs)$coefficients[2,1], summary(si21.attitudes)$coefficients[2,1], summary(si21.full)$coefficients[2,1], summary(si22.bare)$coefficients[2,1], summary(si22.demogs)$coefficients[2,1], summary(si22.attitudes)$coefficients[2,1], summary(si22.full)$coefficients[2,1]),
                     se=c(summary(si11.bare)$coefficients[2,2], summary(si11.demogs)$coefficients[2,2], summary(si11.attitudes)$coefficients[2,2], summary(si11.full)$coefficients[2,2], summary(si12.bare)$coefficients[2,2], summary(si12.demogs)$coefficients[2,2], summary(si12.attitudes)$coefficients[2,2], summary(si12.full)$coefficients[2,2], summary(si13.bare)$coefficients[2,2], summary(si13.demogs)$coefficients[2,2], summary(si13.attitudes)$coefficients[2,2], summary(si13.full)$coefficients[2,2], summary(si14.bare)$coefficients[2,2], summary(si14.demogs)$coefficients[2,2], summary(si14.attitudes)$coefficients[2,2], summary(si14.full)$coefficients[2,2], summary(si15.bare)$coefficients[2,2], summary(si15.demogs)$coefficients[2,2], summary(si15.attitudes)$coefficients[2,2], summary(si15.full)$coefficients[2,2], summary(si16.bare)$coefficients[2,2], summary(si16.demogs)$coefficients[2,2], summary(si16.attitudes)$coefficients[2,2], summary(si16.full)$coefficients[2,2], summary(si17.bare)$coefficients[2,2], summary(si17.demogs)$coefficients[2,2], summary(si17.attitudes)$coefficients[2,2], summary(si17.full)$coefficients[2,2], summary(si18.bare)$coefficients[2,2], summary(si18.demogs)$coefficients[2,2], summary(si18.attitudes)$coefficients[2,2], summary(si18.full)$coefficients[2,2], summary(si19.bare)$coefficients[2,2], summary(si19.demogs)$coefficients[2,2], summary(si19.attitudes)$coefficients[2,2], summary(si19.full)$coefficients[2,2], summary(si20.bare)$coefficients[2,2], summary(si20.demogs)$coefficients[2,2], summary(si20.attitudes)$coefficients[2,2], summary(si20.full)$coefficients[2,2], summary(si21.bare)$coefficients[2,2], summary(si21.demogs)$coefficients[2,2], summary(si21.attitudes)$coefficients[2,2], summary(si21.full)$coefficients[2,2], summary(si22.bare)$coefficients[2,2], summary(si22.demogs)$coefficients[2,2], summary(si22.attitudes)$coefficients[2,2], summary(si22.full)$coefficients[2,2]))
f2data$lci <- f2data$Effect-(1.96*f2data$se)
f2data$uci <- f2data$Effect+(1.96*f2data$se)
## Create Figure
f2 <- ggplot(f2data,aes(x=Outcome,y=Effect,group=Model,color=Model)) + geom_point(position=position_dodge(0.6)) + geom_errorbar(aes(ymin=lci,ymax=uci),lwd=0.5,width=0,position=position_dodge(0.6)) + theme_classic() + scale_color_manual(values=c("#000000", "#E69F00", "#56B4E9", "#009E73")) + theme(legend.position="bottom") + geom_hline(yintercept=0,linetype="dashed") + facet_wrap(vars(predictor),nrow=2,ncol=2)
## Calculate VIF
car::vif(si11.demogs)
car::vif(si11.attitudes)
car::vif(si11.full)
car::vif(si12.demogs)
car::vif(si12.attitudes)
car::vif(si12.full)
car::vif(si13.demogs)
car::vif(si13.attitudes)
car::vif(si13.full)
car::vif(si14.demogs)
car::vif(si14.attitudes)
car::vif(si14.full)
car::vif(si15.demogs)
car::vif(si15.attitudes)
car::vif(si15.full)
car::vif(si16.demogs)
car::vif(si16.attitudes)
car::vif(si16.full)
car::vif(si17.demogs)
car::vif(si17.attitudes)
car::vif(si17.full)
car::vif(si18.demogs)
car::vif(si18.attitudes)
car::vif(si18.full)
car::vif(si19.demogs)
car::vif(si19.attitudes)
car::vif(si19.full)
car::vif(si20.demogs)
car::vif(si20.attitudes)
car::vif(si20.full)
car::vif(si21.demogs)
car::vif(si21.attitudes)
car::vif(si21.full)
car::vif(si22.demogs)
car::vif(si22.attitudes)
car::vif(si22.full)

# Table SI1
data.frame(na.omit(data %>% group_by(region) %>% summarise(n1=mean(northern_resentment1a,na.rm=T),n1_lci=mean(northern_resentment1a,na.rm=T)-(1.96*std.error(northern_resentment1a,na.rm=T)),n1_uci=mean(northern_resentment1a,na.rm=T)+(1.96*std.error(northern_resentment1a,na.rm=T)),
                                                              n2=mean(northern_resentment2a,na.rm=T),n2_lci=mean(northern_resentment2a,na.rm=T)-(1.96*std.error(northern_resentment2a,na.rm=T)),n2_uci=mean(northern_resentment2a,na.rm=T)+(1.96*std.error(northern_resentment2a,na.rm=T)),
                                                              n3=mean(northern_resentment3a,na.rm=T),n3_lci=mean(northern_resentment3a,na.rm=T)-(1.96*std.error(northern_resentment3a,na.rm=T)),n3_uci=mean(northern_resentment3a,na.rm=T)+(1.96*std.error(northern_resentment3a,na.rm=T)),
                                                              n4=mean(northern_resentment4a,na.rm=T),n4_lci=mean(northern_resentment4a,na.rm=T)-(1.96*std.error(northern_resentment4a,na.rm=T)),n4_uci=mean(northern_resentment4a,na.rm=T)+(1.96*std.error(northern_resentment4a,na.rm=T)),
                                                              n5=mean(northern_resentment5a,na.rm=T),n5_lci=mean(northern_resentment5a,na.rm=T)-(1.96*std.error(northern_resentment5a,na.rm=T)),n5_uci=mean(northern_resentment5a,na.rm=T)+(1.96*std.error(northern_resentment5a,na.rm=T)),
                                                              n6=mean(northern_resentment6a,na.rm=T),n6_lci=mean(northern_resentment6a,na.rm=T)-(1.96*std.error(northern_resentment6a,na.rm=T)),n6_uci=mean(northern_resentment6a,na.rm=T)+(1.96*std.error(northern_resentment6a,na.rm=T)),
                                                              n7=mean(northern_resentment7a,na.rm=T),n7_lci=mean(northern_resentment7a,na.rm=T)-(1.96*std.error(northern_resentment7a,na.rm=T)),n7_uci=mean(northern_resentment7a,na.rm=T)+(1.96*std.error(northern_resentment7a,na.rm=T)),
                                                              n8=mean(northern_resentment8a,na.rm=T),n8_lci=mean(northern_resentment8a,na.rm=T)-(1.96*std.error(northern_resentment8a,na.rm=T)),n8_uci=mean(northern_resentment8a,na.rm=T)+(1.96*std.error(northern_resentment8a,na.rm=T)))))

# Table SI2
data.frame(na.omit(data %>% group_by(region) %>% summarise(s1=mean(southern_resentment1a,na.rm=T),s1_lci=mean(southern_resentment1a,na.rm=T)-(1.96*std.error(southern_resentment1a,na.rm=T)),s1_uci=mean(southern_resentment1a,na.rm=T)+(1.96*std.error(southern_resentment1a,na.rm=T)),
                                                              s2=mean(southern_resentment2a,na.rm=T),s2_lci=mean(southern_resentment2a,na.rm=T)-(1.96*std.error(southern_resentment2a,na.rm=T)),s2_uci=mean(southern_resentment2a,na.rm=T)+(1.96*std.error(southern_resentment2a,na.rm=T)),
                                                              s3=mean(southern_resentment3a,na.rm=T),s3_lci=mean(southern_resentment3a,na.rm=T)-(1.96*std.error(southern_resentment3a,na.rm=T)),s3_uci=mean(southern_resentment3a,na.rm=T)+(1.96*std.error(southern_resentment3a,na.rm=T)),
                                                              s4=mean(southern_resentment4a,na.rm=T),s4_lci=mean(southern_resentment4a,na.rm=T)-(1.96*std.error(southern_resentment4a,na.rm=T)),s4_uci=mean(southern_resentment4a,na.rm=T)+(1.96*std.error(southern_resentment4a,na.rm=T)),
                                                              s5=mean(southern_resentment5a,na.rm=T),s5_lci=mean(southern_resentment5a,na.rm=T)-(1.96*std.error(southern_resentment5a,na.rm=T)),s5_uci=mean(southern_resentment5a,na.rm=T)+(1.96*std.error(southern_resentment5a,na.rm=T)),
                                                              s6=mean(southern_resentment6a,na.rm=T),s6_lci=mean(southern_resentment6a,na.rm=T)-(1.96*std.error(southern_resentment6a,na.rm=T)),s6_uci=mean(southern_resentment6a,na.rm=T)+(1.96*std.error(southern_resentment6a,na.rm=T)),
                                                              s7=mean(southern_resentment7a,na.rm=T),s7_lci=mean(southern_resentment7a,na.rm=T)-(1.96*std.error(southern_resentment7a,na.rm=T)),s7_uci=mean(southern_resentment7a,na.rm=T)+(1.96*std.error(southern_resentment7a,na.rm=T)),
                                                              s8=mean(southern_resentment8a,na.rm=T),s8_lci=mean(southern_resentment8a,na.rm=T)-(1.96*std.error(southern_resentment8a,na.rm=T)),s8_uci=mean(southern_resentment8a,na.rm=T)+(1.96*std.error(southern_resentment8a,na.rm=T)))))

# Table SI3
data.frame(na.omit(data %>% group_by(region) %>% summarise(p1=mean(elsewhere_resent1a,na.rm=T),p1_lci=mean(elsewhere_resent1a,na.rm=T)-(1.96*std.error(elsewhere_resent1a,na.rm=T)),p1_uci=mean(elsewhere_resent1a,na.rm=T)+(1.96*std.error(elsewhere_resent1a,na.rm=T)),
                                                              p2=mean(elsewhere_resent2a,na.rm=T),p2_lci=mean(elsewhere_resent2a,na.rm=T)-(1.96*std.error(elsewhere_resent2a,na.rm=T)),p2_uci=mean(elsewhere_resent2a,na.rm=T)+(1.96*std.error(elsewhere_resent2a,na.rm=T)),
                                                              p3=mean(elsewhere_resent3a,na.rm=T),p3_lci=mean(elsewhere_resent3a,na.rm=T)-(1.96*std.error(elsewhere_resent3a,na.rm=T)),p3_uci=mean(elsewhere_resent3a,na.rm=T)+(1.96*std.error(elsewhere_resent3a,na.rm=T)),
                                                              p4=mean(elsewhere_resent4a,na.rm=T),p4_lci=mean(elsewhere_resent4a,na.rm=T)-(1.96*std.error(elsewhere_resent4a,na.rm=T)),p4_uci=mean(elsewhere_resent4a,na.rm=T)+(1.96*std.error(elsewhere_resent4a,na.rm=T)),
                                                              p5=mean(elsewhere_resent5a,na.rm=T),p5_lci=mean(elsewhere_resent5a,na.rm=T)-(1.96*std.error(elsewhere_resent5a,na.rm=T)),p5_uci=mean(elsewhere_resent5a,na.rm=T)+(1.96*std.error(elsewhere_resent5a,na.rm=T)),
                                                              p6=mean(elsewhere_resent6a,na.rm=T),p6_lci=mean(elsewhere_resent6a,na.rm=T)-(1.96*std.error(elsewhere_resent6a,na.rm=T)),p6_uci=mean(elsewhere_resent6a,na.rm=T)+(1.96*std.error(elsewhere_resent6a,na.rm=T)),
                                                              p7=mean(elsewhere_resent7a,na.rm=T),p7_lci=mean(elsewhere_resent7a,na.rm=T)-(1.96*std.error(elsewhere_resent7a,na.rm=T)),p7_uci=mean(elsewhere_resent7a,na.rm=T)+(1.96*std.error(elsewhere_resent7a,na.rm=T)),
                                                              p8=mean(elsewhere_resent8a,na.rm=T),p8_lci=mean(elsewhere_resent8a,na.rm=T)-(1.96*std.error(elsewhere_resent8a,na.rm=T)),p8_uci=mean(elsewhere_resent8a,na.rm=T)+(1.96*std.error(elsewhere_resent8a,na.rm=T)))))

# Table SI4
northern.cfa.configural <- cfa(northern,data=subset(data,is.na(northernresentment)==F),group="region")
northern.cfa.metric <- cfa(northern,data=subset(data,is.na(northernresentment)==F),group="region",group.equal="loadings")
northern.cfa.scalar <- cfa(northern,data=subset(data,is.na(northernresentment)==F),group="region",group.equal=c("loadings","intercepts"))
n.invariance <- compareFit(northern.cfa.configural,northern.cfa.metric,northern.cfa.scalar)

# Table SI5
southern.cfa.configural <- cfa(southern,data=subset(data,is.na(southernresentment)==F),group="region")
southern.cfa.metric <- cfa(southern,data=subset(data,is.na(southernresentment)==F),group="region",group.equal="loadings")
southern.cfa.scalar <- cfa(southern,data=subset(data,is.na(southernresentment)==F),group="region",group.equal=c("loadings","intercepts"))
s.invariance <- compareFit(southern.cfa.configural,southern.cfa.metric,southern.cfa.scalar)

# Table SI6
elsewhere.cfa.configural <- cfa(elsewhere,data=subset(data,is.na(elsewhereresentment)==F),group="region")
elsewhere.cfa.metric <- cfa(elsewhere,data=subset(data,is.na(elsewhereresentment)==F),group="region",group.equal="loadings")
elsewhere.cfa.scalar <- cfa(elsewhere,data=subset(data,is.na(elsewhereresentment)==F),group="region",group.equal=c("loadings","intercepts"))
p.invariance <- compareFit(elsewhere.cfa.configural,elsewhere.cfa.metric,elsewhere.cfa.scalar)

# Table SI7
## Alphas
psych::alpha(cbind.data.frame(data$northern_resentment1a,data$northern_resentment2a,data$northern_resentment3a,data$northern_resentment4a,data$northern_resentment5a,data$northern_resentment6a,data$northern_resentment7a,data$northern_resentment8a))
## CFAs
northern1 <- 'ns =~ northern_resentment2a+northern_resentment3a+northern_resentment4a+northern_resentment5a+northern_resentment6a+northern_resentment7a+northern_resentment8a'
northern2 <- 'ns =~ northern_resentment1a+northern_resentment3a+northern_resentment4a+northern_resentment5a+northern_resentment6a+northern_resentment7a+northern_resentment8a'
northern3 <- 'ns =~ northern_resentment1a+northern_resentment2a+northern_resentment4a+northern_resentment5a+northern_resentment6a+northern_resentment7a+northern_resentment8a'
northern4 <- 'ns =~ northern_resentment1a+northern_resentment2a+northern_resentment3a+northern_resentment5a+northern_resentment6a+northern_resentment7a+northern_resentment8a'
northern5 <- 'ns =~ northern_resentment1a+northern_resentment2a+northern_resentment3a+northern_resentment4a+northern_resentment6a+northern_resentment7a+northern_resentment8a'
northern6 <- 'ns =~ northern_resentment1a+northern_resentment2a+northern_resentment3a+northern_resentment4a+northern_resentment5a+northern_resentment7a+northern_resentment8a'
northern7 <- 'ns =~ northern_resentment1a+northern_resentment2a+northern_resentment3a+northern_resentment4a+northern_resentment5a+northern_resentment6a+northern_resentment8a'
northern8 <- 'ns =~ northern_resentment1a+northern_resentment2a+northern_resentment3a+northern_resentment4a+northern_resentment5a+northern_resentment6a+northern_resentment7a'
northern.1 <- cfa(northern1,data=data)
northern.2 <- cfa(northern2,data=data)
northern.3 <- cfa(northern3,data=data)
northern.4 <- cfa(northern4,data=data)
northern.5 <- cfa(northern5,data=data)
northern.6 <- cfa(northern6,data=data)
northern.7 <- cfa(northern7,data=data)
northern.8 <- cfa(northern8,data=data)

# Table SI8
## Alphas
psych::alpha(cbind.data.frame(data$southern_resentment1a,data$southern_resentment2a,data$southern_resentment3a,data$southern_resentment4a,data$southern_resentment5a,data$southern_resentment6a,data$southern_resentment7a,data$southern_resentment8a))
## CFAs
southern1 <- 'ns =~ southern_resentment2a+southern_resentment3a+southern_resentment4a+southern_resentment5a+southern_resentment6a+southern_resentment7a+southern_resentment8a'
southern2 <- 'ns =~ southern_resentment1a+southern_resentment3a+southern_resentment4a+southern_resentment5a+southern_resentment6a+southern_resentment7a+southern_resentment8a'
southern3 <- 'ns =~ southern_resentment1a+southern_resentment2a+southern_resentment4a+southern_resentment5a+southern_resentment6a+southern_resentment7a+southern_resentment8a'
southern4 <- 'ns =~ southern_resentment1a+southern_resentment2a+southern_resentment3a+southern_resentment5a+southern_resentment6a+southern_resentment7a+southern_resentment8a'
southern5 <- 'ns =~ southern_resentment1a+southern_resentment2a+southern_resentment3a+southern_resentment4a+southern_resentment6a+southern_resentment7a+southern_resentment8a'
southern6 <- 'ns =~ southern_resentment1a+southern_resentment2a+southern_resentment3a+southern_resentment4a+southern_resentment5a+southern_resentment7a+southern_resentment8a'
southern7 <- 'ns =~ southern_resentment1a+southern_resentment2a+southern_resentment3a+southern_resentment4a+southern_resentment5a+southern_resentment6a+southern_resentment8a'
southern8 <- 'ns =~ southern_resentment1a+southern_resentment2a+southern_resentment3a+southern_resentment4a+southern_resentment5a+southern_resentment6a+southern_resentment7a'
southern.1 <- cfa(southern1,data=data)
southern.2 <- cfa(southern2,data=data)
southern.3 <- cfa(southern3,data=data)
southern.4 <- cfa(southern4,data=data)
southern.5 <- cfa(southern5,data=data)
southern.6 <- cfa(southern6,data=data)
southern.7 <- cfa(southern7,data=data)
southern.8 <- cfa(southern8,data=data)

# Table SI9
## Alphas
psych::alpha(cbind.data.frame(data$elsewhere_resent1a,data$elsewhere_resent2a,data$elsewhere_resent3a,data$elsewhere_resent4a,data$elsewhere_resent5a,data$elsewhere_resent6a,data$elsewhere_resent7a,data$elsewhere_resent8a))
## CFAs
peripheral1 <- 'ns =~ elsewhere_resent2a+elsewhere_resent3a+elsewhere_resent4a+elsewhere_resent5a+elsewhere_resent6a+elsewhere_resent7a+elsewhere_resent8a'
peripheral2 <- 'ns =~ elsewhere_resent1a+elsewhere_resent3a+elsewhere_resent4a+elsewhere_resent5a+elsewhere_resent6a+elsewhere_resent7a+elsewhere_resent8a'
peripheral3 <- 'ns =~ elsewhere_resent1a+elsewhere_resent2a+elsewhere_resent4a+elsewhere_resent5a+elsewhere_resent6a+elsewhere_resent7a+elsewhere_resent8a'
peripheral4 <- 'ns =~ elsewhere_resent1a+elsewhere_resent2a+elsewhere_resent3a+elsewhere_resent5a+elsewhere_resent6a+elsewhere_resent7a+elsewhere_resent8a'
peripheral5 <- 'ns =~ elsewhere_resent1a+elsewhere_resent2a+elsewhere_resent3a+elsewhere_resent4a+elsewhere_resent6a+elsewhere_resent7a+elsewhere_resent8a'
peripheral6 <- 'ns =~ elsewhere_resent1a+elsewhere_resent2a+elsewhere_resent3a+elsewhere_resent4a+elsewhere_resent5a+elsewhere_resent7a+elsewhere_resent8a'
peripheral7 <- 'ns =~ elsewhere_resent1a+elsewhere_resent2a+elsewhere_resent3a+elsewhere_resent4a+elsewhere_resent5a+elsewhere_resent6a+elsewhere_resent8a'
peripheral8 <- 'ns =~ elsewhere_resent1a+elsewhere_resent2a+elsewhere_resent3a+elsewhere_resent4a+elsewhere_resent5a+elsewhere_resent6a+elsewhere_resent7a'
peripheral.1 <- cfa(peripheral1,data=data)
peripheral.2 <- cfa(peripheral2,data=data)
peripheral.3 <- cfa(peripheral3,data=data)
peripheral.4 <- cfa(peripheral4,data=data)
peripheral.5 <- cfa(peripheral5,data=data)
peripheral.6 <- cfa(peripheral6,data=data)
peripheral.7 <- cfa(peripheral7,data=data)
peripheral.8 <- cfa(peripheral8,data=data)

# Table SI10
## Alphas
psych::alpha(cbind.data.frame(data$london_resent1a,data$london_resent2a,data$london_resent3a,data$london_resent4a,data$london_resent5a,data$london_resent6a,data$london_resent7a,data$london_resent8a))## CFAs
## CFAs
central1 <- 'ns =~ london_resent2a+london_resent3a+london_resent4a+london_resent5a+london_resent6a+london_resent7a+london_resent8a'
central2 <- 'ns =~ london_resent1a+london_resent3a+london_resent4a+london_resent5a+london_resent6a+london_resent7a+london_resent8a'
central3 <- 'ns =~ london_resent1a+london_resent2a+london_resent4a+london_resent5a+london_resent6a+london_resent7a+london_resent8a'
central4 <- 'ns =~ london_resent1a+london_resent2a+london_resent3a+london_resent5a+london_resent6a+london_resent7a+london_resent8a'
central5 <- 'ns =~ london_resent1a+london_resent2a+london_resent3a+london_resent4a+london_resent6a+london_resent7a+london_resent8a'
central6 <- 'ns =~ london_resent1a+london_resent2a+london_resent3a+london_resent4a+london_resent5a+london_resent7a+london_resent8a'
central7 <- 'ns =~ london_resent1a+london_resent2a+london_resent3a+london_resent4a+london_resent5a+london_resent6a+london_resent8a'
central8 <- 'ns =~ london_resent1a+london_resent2a+london_resent3a+london_resent4a+london_resent5a+london_resent6a+london_resent7a'
central.1 <- cfa(central1,data=data)
central.2 <- cfa(central2,data=data)
central.3 <- cfa(central3,data=data)
central.4 <- cfa(central4,data=data)
central.5 <- cfa(central5,data=data)
central.6 <- cfa(central6,data=data)
central.7 <- cfa(central7,data=data)
central.8 <- cfa(central8,data=data)

# Table SI23
si23.bare <- lm(ft_tory~elsewhereresentment,data=data,subset=region!="North West")
si23.demogs <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="North West")
si23.attitudes <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="North West")
si23.full <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="North West")

# Table SI24
si24.bare <- lm(ft_tory~elsewhereresentment,data=data,subset=region!="North East")
si24.demogs <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="North East")
si24.attitudes <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="North East")
si24.full <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="North East")

# Table SI25
si25.bare <- lm(ft_tory~elsewhereresentment,data=data,subset=region!="Yorkshire and the Humber")
si25.demogs <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="Yorkshire and the Humber")
si25.attitudes <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="Yorkshire and the Humber")
si25.full <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="Yorkshire and the Humber")

# Table SI26
si26.bare <- lm(ft_tory~elsewhereresentment,data=data,subset=region!="West Midlands")
si26.demogs <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="West Midlands")
si26.attitudes <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="West Midlands")
si26.full <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="West Midlands")

# Table SI27
si27.bare <- lm(ft_tory~elsewhereresentment,data=data,subset=region!="East Midlands")
si27.demogs <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="East Midlands")
si27.attitudes <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="East Midlands")
si27.full <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="East Midlands")

# Table SI28
si28.bare <- lm(ft_tory~elsewhereresentment,data=data,subset=region!="East of England")
si28.demogs <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="East of England")
si28.attitudes <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="East of England")
si28.full <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="East of England")

# Table SI29
si29.bare <- lm(ft_tory~elsewhereresentment,data=data,subset=region!="South West")
si29.demogs <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="South West")
si29.attitudes <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="South West")
si29.full <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="South West")

# Table SI30
si30.bare <- lm(ft_tory~elsewhereresentment,data=data,subset=region!="South East")
si30.demogs <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="South East")
si30.attitudes <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="South East")
si30.full <- lm(ft_tory~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="South East")

# Table SI31
si31.bare <- lm(torylikely~elsewhereresentment,data=data,subset=region!="North West")
si31.demogs <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="North West")
si31.attitudes <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="North West")
si31.full <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="North West")

# Table SI32
si32.bare <- lm(torylikely~elsewhereresentment,data=data,subset=region!="North East")
si32.demogs <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="North East")
si32.attitudes <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="North East")
si32.full <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="North East")

# Table SI33
si33.bare <- lm(torylikely~elsewhereresentment,data=data,subset=region!="Yorkshire and the Humber")
si33.demogs <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="Yorkshire and the Humber")
si33.attitudes <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="Yorkshire and the Humber")
si33.full <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="Yorkshire and the Humber")

# Table SI34
si34.bare <- lm(torylikely~elsewhereresentment,data=data,subset=region!="West Midlands")
si34.demogs <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="West Midlands")
si34.attitudes <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="West Midlands")
si34.full <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="West Midlands")

# Table SI35
si35.bare <- lm(torylikely~elsewhereresentment,data=data,subset=region!="East Midlands")
si35.demogs <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="East Midlands")
si35.attitudes <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="East Midlands")
si35.full <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="East Midlands")

# Table SI36
si36.bare <- lm(torylikely~elsewhereresentment,data=data,subset=region!="East of England")
si36.demogs <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="East of England")
si36.attitudes <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="East of England")
si36.full <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="East of England")

# Table SI37
si37.bare <- lm(torylikely~elsewhereresentment,data=data,subset=region!="South West")
si37.demogs <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="South West")
si37.attitudes <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="South West")
si37.full <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="South West")

# Table SI38
si38.bare <- lm(torylikely~elsewhereresentment,data=data,subset=region!="South East")
si38.demogs <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="South East")
si38.attitudes <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="South East")
si38.full <- lm(torylikely~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="South East")

# Table SI39
si39.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="North West")
si39.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="North West")
si39.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="North West")
si39.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="North West")

# Table SI40
si40.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="North East")
si40.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="North East")
si40.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="North East")
si40.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="North East")

# Table SI41
si41.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="Yorkshire and the Humber")
si41.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="Yorkshire and the Humber")
si41.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="Yorkshire and the Humber")
si41.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="Yorkshire and the Humber")

# Table SI42
si42.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="West Midlands")
si42.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="West Midlands")
si42.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="West Midlands")
si42.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="West Midlands")

# Table SI43
si43.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="East Midlands")
si43.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="East Midlands")
si43.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="East Midlands")
si43.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="East Midlands")

# Table SI44
si44.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="East of England")
si44.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="East of England")
si44.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="East of England")
si44.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="East of England")

# Table SI45
si45.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="South West")
si45.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="South West")
si45.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="South West")
si45.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="South West")

# Table SI46
si46.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="South East")
si46.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="South East")
si46.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="South East")
si46.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="South East")

# Table SI47
si47.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="North West")
si47.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="North West")
si47.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="North West")
si47.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="North West")

# Table SI48
si48.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="North East")
si48.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="North East")
si48.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="North East")
si48.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="North East")

# Table SI49
si49.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="Yorkshire and the Humber")
si49.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="Yorkshire and the Humber")
si49.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="Yorkshire and the Humber")
si49.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="Yorkshire and the Humber")

# Table SI50
si50.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="West Midlands")
si50.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="West Midlands")
si50.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="West Midlands")
si50.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="West Midlands")

# Table SI51
si51.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="East Midlands")
si51.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="East Midlands")
si51.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="East Midlands")
si51.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="East Midlands")

# Table SI52
si52.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="East of England")
si52.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="East of England")
si52.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="East of England")
si52.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="East of England")

# Table SI53
si53.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="South West")
si53.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="South West")
si53.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="South West")
si53.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="South West")

# Table SI54
si54.bare <- lm(ft_labour~elsewhereresentment,data=data,subset=region!="South East")
si54.demogs <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000,data=data,subset=region!="South East")
si54.attitudes <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data,subset=region!="South East")
si54.full <- lm(ft_labour~elsewhereresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data,subset=region!="South East")

# Table SI55
si55.bare <- lm(ft_tory~londonresentment,data=data)
si55.demogs <- lm(ft_tory~londonresentment+longlive+age+male+white+income_000,data=data)
si55.attitudes <- lm(ft_tory~londonresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si55.full <- lm(ft_tory~londonresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)

# Table SI56
si56.bare <- lm(torylikely~londonresentment,data=data)
si56.demogs <- lm(torylikely~londonresentment+longlive+age+male+white+income_000,data=data)
si56.attitudes <- lm(torylikely~londonresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si56.full <- lm(torylikely~londonresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)

# Table SI57
si57.bare <- lm(ft_labour~londonresentment,data=data)
si57.demogs <- lm(ft_labour~londonresentment+longlive+age+male+white+income_000,data=data)
si57.attitudes <- lm(ft_labour~londonresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si57.full <- lm(ft_labour~londonresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)

# Table SI58
si58.bare <- lm(labourlikely~londonresentment,data=data)
si58.demogs <- lm(labourlikely~londonresentment+longlive+age+male+white+income_000,data=data)
si58.attitudes <- lm(labourlikely~londonresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born,data=data)
si58.full <- lm(labourlikely~londonresentment+longlive+age+male+white+income_000+costofliving+business+immigration7+british_born+partyid,data=data)